$(function() {

	// Define Media Variables
	var media = $("div#media"),
		mediaUl = media.children('ul'),
		mediaUlLi = mediaUl.children('li'),
		mediaA = media.find('a'),
		productTitle = $("div#product-title");
		

	// Override Slider Default Settings
	$.anythingSlider.defaults.hashTags 			= false;
	$.anythingSlider.defaults.expand 			= true;
	$.anythingSlider.defaults.buildStartStop 	= false;
	$.anythingSlider.defaults.infiniteSlides 	= false;
	$.anythingSlider.defaults.autoPlay 			= mediaAutoPlay;

	// Setup Media Slider
	if ( thumbsPosition == 'bottom' ) // if thumbs position bottom
	{ 

		
		mediaUl.anythingSlider({			
			navigationFormatter : function(i){
				return '<img src="'+thumbs[i-1]+'" width="45" height="30" />';
			},
			navigationSize : 5							
		});	

		// Add .anythingControlsBottom Class, if Bottom Position Was Selected
		var anythingControls = media.find('.anythingControls'),
			thumbNav = media.find('.thumbNav li');

		if( thumbNav.length )
		{
			productTitle.css('marginTop', 40);
		}

		anythingControls.addClass('anythingControlsBottom');		

	} 
	else if ( thumbsPosition == 'top' ) // if thumbs position top
	{
		mediaUl.anythingSlider({
			navigationFormatter : function(i){
				return '<img src="'+thumbs[i-1]+'" width="45" height="30" />';
			},
			navigationSize : 5			
		});	

		// Add .anythingControlsTop Class, if Top Position Was Selected
		var anythingControls = media.find('.anythingControls');
		anythingControls.addClass('anythingControlsTop').hide();

		media.hover(function() {
			anythingControls.stop(true,true).fadeIn();
		}, function() {
			anythingControls.stop(true,true).fadeOut();
		});

	} 

	else // if thumbs not at all
	{

		mediaUl.anythingSlider({			
			buildNavigation: false									
		});	

	}
		

	// On Hover Slideup Description ( If Has )
	mediaUlLi.hover(function() {		
		$(this).find('div.caption').stop(true,true).slideDown();
	}, function() {
		$(this).find('div.caption').stop(true,true).slideUp();
	});

	// Disable default action for a links in Media
	mediaA.on('click', function() {
		return false;
	});

});